/**
 * @date 2022/4/1
 * @description router.js
 * @author 
 */

import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layouts/index.vue'

export const constantRoutes = [{
    path: '/login',
    component: () =>
        import('@/views/login/index.vue'),
    meta: {
        title: '登录',
    },
    hidden: true,
},
{
    path: '/404',
    name: '404',
    meta: {
        title: '404',
    },
    component: () =>
        import('@/views/errorPage/404.vue'),
    hidden: true,
},
]

export const commonRoutes = [{
    path: '/personCenter',
    name: 'PersonCenter',
    meta: {
        title: '个人中心',
        isShow: false,
        level: 2,
    },
    component: () =>
        import('@/views/personCenter/index.vue'),
    hidden: true,
},]

const router = createRouter({
    history: createWebHashHistory(),
    routes: constantRoutes,
})

// reset router
export function resetRouter() {
    router.getRoutes().forEach((route) => {
        const { name } = route
        if (name) {
            router.hasRoute(name) && router.removeRoute(name)
        }
    })
}

export default router